package com.thb.pay.manage.web.merchant;


import com.thb.pay.api.merchant.MchAccountServiceApi;
import com.thb.pay.api.merchant.vo.req.MchAccountPageReq;
import com.thb.pay.api.merchant.vo.req.MchAccountReq;
import com.thb.pay.api.merchant.vo.resp.MchAccountVo;
import com.thb.pay.core.utils.PageResult;
import com.thb.pay.core.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 商户-账户表 前端控制器
 * </p>
 *
 * @author lucky
 * @since 2019-07-21
 */
@RestController
@RequestMapping("/api/sys/mchAccount")
public class MchAccountController {

    @Autowired
    private MchAccountServiceApi mchAccountServiceApi;

    @PostMapping("/list")
    public R list(@RequestBody MchAccountPageReq pageReq) {
        PageResult<MchAccountVo> pageResult = mchAccountServiceApi.findPage(pageReq);
        return R.okData(pageResult);
    }

    @RequestMapping("/get")
    public R get(@RequestParam("id") Long id) {
        MchAccountVo resultData = mchAccountServiceApi.getById(id);
        return R.okData(resultData);
    }

    @PostMapping("/add")
    public R add(@RequestBody MchAccountReq mchAccountReq) {
        mchAccountServiceApi.add(mchAccountReq);
        return R.ok();
    }

    @PostMapping("/update")
    public R update(@RequestBody MchAccountReq mchAccountReq) {
        mchAccountServiceApi.update(mchAccountReq);
        return R.ok();
    }
}
